﻿<div ng-controller="studentController">

    <form class="form-horizontal" ng-submit="save()" ng-show="formVisibility">

        <div class="form-group">
            <label class="control-label col-xs-3">Codigo:</label>
            <div class="col-xs-9">
                <input type="text" class="form-control" placeholder="Codigo" ng-model="student.CodigoM" required>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-xs-3">Nombre:</label>
            <div class="col-xs-9">
                <input type="text" class="form-control" placeholder="Nombre" ng-model="student.Nombre" required>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-xs-3">Apellido:</label>
            <div class="col-xs-9">
                <input type="text" class="form-control" placeholder="Apellido" ng-model="student.Apellidos" required>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-xs-3">DNI:</label>
            <div class="col-xs-9">
                <input type="text" class="form-control" placeholder="DNI" ng-model="student.DNI" required>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-xs-3">Dirección:</label>
            <div class="col-xs-9">
                <textarea rows="3" class="form-control" placeholder="Dirección" ng-model="student.Direccion" required></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-xs-3">F.Nacimiento:</label>
            <div class="col-xs-9">
                <input type="date" class="form-control" placeholder="F.Nacimiento" ng-model="student.FechaNac" required>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-xs-3">Tutor :</label>
            <div class="col-xs-9">
                <select ng-model="student.Tutor_Id"
                        ng-options="value.Tutor_Id as value.Nombre for value in tutorList">
                    <option>--</option>
                </select>  {{student.Tutor_Id}}
            </div>
        </div>

        <br>
        <div class="form-group">
            <div class="col-xs-offset-3 col-xs-9">
                <button type="button" class="btn btn-default" ng-click="cancel()">Cancel </button>
                <button class="btn btn-success " type="submit">Save</button>
                </div>
            </div>
        
    </form>
<div>
    <h3>LISTA DE ESTUDIANTES</h3>
    <div class="table-responsive">
        <table class="table table-striped tab-content table-bordered">
            <tr>
                <th>Codigo</th>
                <th>Nombre</th>
                <th>Apellidos</th>
                <th>DNI</th>
                <th>Direcciòn</th>
                <th>Fecha de Nacimiento</th>
                <th>Nombre de Tutor</th>
                <th>Opciones</th>
            </tr>
            <tr data-ng-repeat="d in list">

                <td> {{d.CodigoM}}</td>
                <td>{{d.Nombre}}</td>
                <td> {{d.Apellidos}}</td>
                <td> {{d.DNI}}</td>
                <td> {{d.Direccion}}</td>
                <td> {{d.FechaNac}} </td>
                <td>{{d.TutorModel.Nombre}}</td>
                <td>
                    <button ng-click="getById(d)" type="button" class="btn btn-primary"><i class="glyphicon glyphicon-pencil"></i> <span>Editar</span></button>
                    <button ng-click="delete(d)" type="button" class="btn btn-danger"><i class="glyphicon glyphicon-trash"></i> <span>Eliminar</span></button>
                </td>

            </tr>
        </table>
    </div>
    <button ng-click="ShowForm()" ng-hide="formVisibility" type="button" class="btn btn-primary"><i class="glyphicon glyphicon-plus"></i> Agregar estudiante</button>
</div>
    </div>
               